﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using RaiderManagerBackend;

namespace RaiderManager.EditWindows
{
    /// <summary>
    /// Interaction logic for EditPerformanceEntryWindow.xaml
    /// </summary>
    public partial class EditPerformanceEntryWindow : Window
    {
        PlayerPerformanceEntry pe;

        public EditPerformanceEntryWindow(PlayerPerformanceEntry performanceEntry)
        {
            InitializeComponent();
            pe = performanceEntry;
            this.EditPerformanceGrid.DataContext = pe;
            this.playerNameDropDown.DataContext = MainRadWindow.players;
            this.playerNameDropDown.SelectedItem = pe.Player;
            this.encountersDropDown.DataContext = pe.Raid;
            pe.Raid.BuildEncounters();
            this.encountersDropDown.SelectedItem = pe.Encounter;
        }

        new public PlayerPerformanceEntry ShowDialog()
        {
            base.ShowDialog();
            return pe;
        }

        private void cancelButton_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult mbr = MessageBox.Show("You leave now, you may never come back!", "What? So Soon?", MessageBoxButton.OKCancel);
            if (mbr.Equals(MessageBoxResult.Cancel))
                return;
            else
                this.Close();
        }

        private void saveButton_Click(object sender, RoutedEventArgs e)
        {
            pe.SavePerformanceEntry();
            pe.Player.CalculatePerformanceGrade();
        }
    }
}
